LLVM-3.1 libLLVMSupport.a undefined reference to `dladdr'

Posted by user91387 on Ask Ubuntu See other posts from Ask Ubuntu or by user91387
Published on 2012-09-19T00:21:29Z Indexed on 2012/10/20 5:22 UTC
Read the original article Hit count: 447

Filed under:

I'm trying to compile using the llvm-3.1 package. I'm running 12.04 x64 (3.2.0-26 kernel) && 12.10 (3.5.0-4) x64 backported llvm-3.1 from quantal, then debian experimental.
Next I tried 12.10 with the native ubuntu llvm-3.1 package; this failed as well.

user@system:/tmp/llvm-test# make  
compiling cpp yacc file: decaf-llvm.y  
output file: decaf-llvm  
bison -b decaf-llvm -d decaf-llvm.y  
/bin/mv -f decaf-llvm.tab.c decaf-llvm.tab.cc  
flex -odecaf-llvm.lex.cc decaf-llvm.lex  
g++ -o ./decaf-llvm decaf-llvm.tab.cc decaf-llvm.lex.cc decaf-stdlib.c `llvm-config --cppflags --ldflags --libs core jit native` -ly -ll  
/usr/lib/llvm-3.1/lib/libLLVMSupport.a(Signals.o): In function `PrintStackTrace(void*)':
(.text+0x6c): undefined reference to `dladdr'  
/usr/lib/llvm-3.1/lib/libLLVMSupport.a(Signals.o): In function `PrintStackTrace(void*)':
(.text+0x18f): undefined reference to `dladdr'  
collect2: error: ld returned 1 exit status  
make: *** [decaf-llvm] Error 1  

I know the code works as I've run it in centos fine using llvm-3.1-6.fc18(rpm)

Google was a bit helpful with this:

"On some systems, incluning Ubuntu 11.10, linking may fail with message that libLLVMSupport.a in function PrintStackTrace(void*) has undefined reference to dladdr."

"Workaround is to compile LLVM with cmake specifying the following variable: -DCMAKE_EXE_LINKER_FLAGS=-ldl"

http://svn.dsource.org/projects/bindings/trunk/llvm-3.0/Readme

I double checked y ldflags and everything seems ok.

user@system:/llvm-config --ldflags
-L/usr/lib/llvm-3.1/lib  -lpthread -lffi -ldl -lm

I'm unclear of what to do next; any suggestions?

© Ask Ubuntu or respective owner

Related posts about compiling